package com.family.menage.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.family.menage.controller.vo.HousesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.family.menage.entity.HousesEntity;
import com.family.menage.service.HousesService;
import com.family.common.utils.PageUtils;
import com.family.common.utils.R;



/**
 * 
 *
 * @author Qzy
 * @email 2434785870@qq.com
 * @date 2021-09-14 19:10:28
 */
@RestController
@RequestMapping("/houses")
public class HousesController {



    @Autowired
    private HousesService housesService;



    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = housesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		HousesEntity houses = housesService.getById(id);

        return R.ok().put("houses", houses);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HousesEntity houses){
		housesService.save(houses);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HousesEntity houses){
		housesService.updateById(houses);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		housesService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
